#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    QDialog *dialog = new SvgFileDialog;
    dialog->setAttribute(Qt::WA_DeleteOnClose);

    dialog->show();
}

void MainWindow::on_pushButton_2_clicked()
{
    QDialog *dialog = new SvgStrDialog;
    dialog->setAttribute(Qt::WA_DeleteOnClose);

    dialog->show();
}

void MainWindow::on_pushButton_3_clicked()
{
    QDialog *dialog = new UrlDialog;
    dialog->setAttribute(Qt::WA_DeleteOnClose);

    dialog->show();
}

void MainWindow::on_pushButton_4_clicked()
{
    QDialog *dialog = new HtmlDialog;
    dialog->setAttribute(Qt::WA_DeleteOnClose);

    dialog->show();
}

void MainWindow::on_pushButton_5_clicked()
{
    // 创建 QProcess 实例
    QProcess process;

    // 启动进程
    process.start("D:\\binx-workspace\\binx-electron\\out\\binx-electron-win32-x64\\binx-electron.exe", {"arg1", "arg2"});
    if (!process.waitForFinished()) {
        qDebug() << "Failed to run exe file";
    }
}

void MainWindow::on_pushButton_7_clicked()
{
    JvmTest *jvmTest = new JvmTest();
    jvmTest->test();
}

void MainWindow::on_pushButton_6_clicked()
{
    QProcess process;
    process.start("java -jar D:\\temp\\demo\\build\\libs\\demo-1.0-SNAPSHOT.jar 1 2");
    if (!process.waitForFinished()) {
        qDebug() << "Failed to run jar file";
    }

    QString output = process.readAllStandardOutput();
    qDebug() << "Jar output: 1 + 2 =" << output;
}

void MainWindow::on_pushButton_8_clicked()
{
    HttpTest *httpTest = new HttpTest();
    httpTest->test();
}

void MainWindow::on_pushButton_9_clicked()
{
    WebSocketTest* webSocketTest=new WebSocketTest();
    webSocketTest->test();
}


